<template>
  <div>
    <div id="videoTop">
      <input type="text" v-model="search" placeholder="搜索企业" @keyup.enter="searchCompany">
      <i @click="searchCompany()" style="cursor:pointer;" class="el-icon-search"></i>
    </div>
    <div class="docs" v-for="item in docs" :key="item.id">
      <div class="img">
        <img :src="require('../../../assets/img/word_logo.png')" alt="">
      </div>
      <div class="content">
        <h5 style="">{{item.title}}</h5>
                <p style="color: red;">{{getCompanyName(item.cid)}}</p>
        <h5 style="float: right;margin-right: 30px">{{item.createTime}}</h5>

        <a :href="url"><el-button @click="downDoc(item.id)" size="mini"><i class="el-icon-download"></i></el-button></a>
      </div>
    </div>
  </div>
</template>

<script>
import {getCompanyPractice} from "../../../network/data";
import {baseUrl} from "../../../network/baseUrl";
import {getTimeBefore} from "@/untils/timeBefore";

export default {
  name:'company',
  data(){
    return{
      search:'',
      baseUrl:baseUrl(),
      dialogVisible:false,
      url:'',
      docs:[

      ],
      fileList:[],
      companyMap:{},
    }
  },
  created() {
    this.getData()
  },
  methods:{
    getTime(time){
      return getTimeBefore(time)
    },
    searchCompany(){
      getCompanyPractice(this.search)
      .then(res=>{
        console.log(res)
        let pm=res.data.extend.practiceMap
        this.docs=[]
        for (let key in pm){
          for (let item of pm[key]){
            this.docs.push(item)
          }
        }
        this.companyMap=res.data.extend.companyMap
      })
    },
    getData(){
      getCompanyPractice()
          .then(res=>{
            console.log(res)
            let pm=res.data.extend.practiceMap
            for (let key in pm){
              for (let item of pm[key]){
                this.docs.push(item)
              }
            }
            this.companyMap=res.data.extend.companyMap
          })
    },
    getCompanyName(cid){
      return this.companyMap[cid].companyName
    },
    downDoc(id){
      this.url=baseUrl()+'/data/downloadPractice/'+id
    },

  }

}
</script>

<style scoped>
#videoTop{
  margin: 10px;
  width: 96%;
  background-color: #ded1d1;
  border-radius: 30px;
  display: flex;
  align-items: center;
  justify-content: space-around;
}
#videoTop input{
  width: 90%;
  outline: none;
  border: none;
  height: 35px;
  background-color: rgba(0,0,0,0);
}
h5{
  padding: 0;
  margin: 0;
}
.docs{
  cursor: pointer;
  width: 100%;
  height: 40px;
  transition: all .1s;
  border-bottom: 1px solid gainsboro;
}
.docs:hover{
  background-color: gainsboro;
}
.docs .img{
  float: left;
  height: 100%;
  width: 60px;
}
.docs img{
  height: 100%;
  width: 100%;
}
.content{
  float: left;
  height: 100%;
  width: 80%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.content h5{
  line-height: 40px;
}
</style>